package com.mc.lp.database.entity.helper;

import java.util.Date;

import com.mc.lp.database.entity.SocialBehaviorRecordEntity;
import com.mc.lp.shared.vo.SocialBehaviorRecordVO;
/*
 * @author aphanda
 * @date Sep 28, 2014
 * @time 12:54:43 AM
 */

public class SocialBehaviorRecordHelper implements IEntityHelper<SocialBehaviorRecordEntity, SocialBehaviorRecordVO> {

	@Override
	public SocialBehaviorRecordVO getVO(SocialBehaviorRecordEntity entity) {
		SocialBehaviorRecordVO vo = new SocialBehaviorRecordVO();

		vo.setGradeId(entity.getGradeId());
		vo.setGradePointId(entity.getGradePointId());
		vo.setNewRow(false);
		vo.setRemarks(entity.getRemarks());
		vo.setSid(entity.getId());
		vo.setSocialBehaviourId(entity.getSocialBehaviourId());
		vo.setTermId(entity.getTermId());
		vo.setAttributeWeightage(entity.getAttributeWeightage());
		
		return vo;
	}

	@Override
	public SocialBehaviorRecordEntity getEntity(SocialBehaviorRecordVO vo) {
		SocialBehaviorRecordEntity entity = new SocialBehaviorRecordEntity();
		setEntity(vo, entity);
		return entity;
	}

	@Override
	public void setEntity(SocialBehaviorRecordVO vo, SocialBehaviorRecordEntity entity) {
		if (vo.isNewRow())
			entity.setCreatedDate(new Date());
		else
			entity.setId(vo.getSid());

		entity.setGradeId(vo.getGradeId());
		entity.setGradePointId(vo.getGradePointId());
		entity.setModifiedDate(new Date());
		entity.setRemarks(vo.getRemarks());
		entity.setSocialBehaviourId(vo.getSocialBehaviourId());
		entity.setTermId(vo.getTermId());
		entity.setAttributeWeightage(vo.getAttributeWeightage());
	}

}
